﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using Konekcija.Core.Reporting.Dto.Application.Meta;

namespace Konekcija.Core.Reporting.Mappings.Meta
{
    public class ItemTypeMap : ClassMap<ItemType>
    {
        public ItemTypeMap()
        {
            Schema("meta");
            Table("ItemTypes");

            Id(x => x.Id).GeneratedBy.GuidComb().Not.Nullable();
            Map(x => x.ParentItemId).Nullable();
            Map(x => x.Path).Nullable();
            Map(x => x.Name).Nullable();
            Map(x => x.Importance).Nullable();
            Map(x => x.Description).Nullable();
            Map(x => x.ImageUrl).Nullable();
            Map(x => x.NumActiveContent).Nullable();
            Map(x => x.DateCreated).Nullable();

            HasManyToMany(x => x.Items)
                .LazyLoad()
                .Inverse()
                .AsBag()
                .Cascade.None()
                .ParentKeyColumn("TypeId")
                .ChildKeyColumn("ItemId")
                .Table("content.ItemsToTypes");
        }
    }
}
